package vn.orderonline.com.core.business.category;

import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import vn.orderonline.core.dao.CategoryDao;
import vn.orderonline.core.dao.entity.Category;

@Service
@Transactional
public class CategoryImpl implements ICategory {
	
	@Autowired
	private CategoryDao categoryDao;

	@Override
	public Map<String, String> getListCategory() {
		List<Category> list = categoryDao.findAll();
		Map<String, String> map = new LinkedHashMap<>();
		if (!list.isEmpty()) {
			for (Category ca : list) {
				map.put(ca.getCategoryId().toString(), ca.getCategoryName());
			}
		}
		return map;
	}

}
